#!/usr/bin/env python
# -*- coding: utf-8 -*-


# from .tools import to_hex_list

from utils.tools import set_csv_data

from random import randint


def get_one():
    one = randint(0, 15)
    one = hex(one)[2:]
    return one


def get_str(num):
    return ''.join([get_one() for index in range(num)])


def main():
    first = [hex(index+8)[2:] for index in range(2)]
    last = [str(index+1) for index in range(3)]
    # print(first, last)

    # codes = ['%s%s0gateway0%s' % (f, f, l) for f in first for l in last]
    # codes = [{'code': c} for c in codes]
    # print(codes)
    # set_csv_data('../reg_data/codes.csv', codes)

    codes = ['%s%s0devicee0%s' % (f, f, l) for f in first for l in last]
    codes = [{
        'device_code': c,
        'sensor_code': '0%s' % s,
        'sensor_type': 'moisture'} for c in codes for s in [1, 2]]
    print(codes)
    set_csv_data('./reg_data/codes.csv', codes)


main()
